// +------------------------------------------------------------------------+
// | XRes - Mac OS X Resource Monitor                                       |
// +------------------------------------------------------------------------+
// | Copyright (c) 2007 Zack Bartel                                         |
// +------------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or          |
// | modify it under the terms of the GNU General Public License            | 
// | as published by the Free Software Foundation; either version 2         | 
// | of the License, or (at your option) any later version.                 |
// |                                                                        |
// | This program is distributed in the hope that it will be useful,        |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of         |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          |
// | GNU General Public License for more details.                           |
// |                                                                        |
// | You should have received a copy of the GNU General Public License      |
// | along with this program; if not, write to the Free Software            |
// | Foundation, Inc., 59 Temple Place - Suite 330,                         |
// | Boston, MA  02111-1307, USA.                                           |
// +------------------------------------------------------------------------+
// | Author: Zack Bartel <zack@bartel.com>                                  |
// +------------------------------------------------------------------------+ 
//
//  XRMemoryGraphDataSource.h
//  XRes
//
//  Created by Zack Bartel on 3/7/08.
//  Copyright 2008 Zack Bartel. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <SM2DGraphView/SMPieChartView.h>
#import <SM2DGraphView/SM2DGraphView.h>
#import "XRProcess.h"

typedef enum _XRMonitorType
{
    XRMonitorRam,
    XRMonitorCpu
} XRMonitorType;

@interface XRMemoryGraphDataSource : NSObject {
    IBOutlet SMPieChartView     *chart;
    IBOutlet NSTableView        *table;
    IBOutlet SM2DGraphView      *graph;
    IBOutlet NSTextField        *processLabel;
    IBOutlet NSImageView        *processIcon;
    IBOutlet NSToolbarItem      *stopButton;
    IBOutlet NSTextField        *pidLabel;
    IBOutlet NSTextField        *pidLabelLabel;
    IBOutlet NSTextField        *userLabel;
    IBOutlet NSTextField        *userLabelLabel;
    IBOutlet NSTextField        *cpuLabel;
    IBOutlet NSTextField        *cpuLabelLabel;
    IBOutlet NSTextField        *ramLabel;
    IBOutlet NSTextField        *ramLabelLabel;
    IBOutlet NSTextField        *commandLabel;
    IBOutlet NSTextField        *commandLabelLabel;
    
    int                         selectedProcess;
    BOOL                        reverseOrderBy;
    NSArray                     *processes;
    NSMutableDictionary         *graphCPUData;
    NSMutableDictionary         *graphMemoryData;
    NSMutableDictionary         *colorMap;
    XRMonitorType               monitorType;
    XRProcessAttribute          processAttributes;
    XRProcessOrderBy            processOrderBy;
}

- (void) loadProcesses: (NSTimer *) timer;
- (int) indexOfProcess: (int) pid;
- (NSColor *) colorForProcess: (XRProcess *) process;
- (NSColor *) getNextColor;
- (void) saveCurrentStateGraphData;
- (void) popArray: (NSMutableArray *) data;
+ (NSString *) bytesToString: (long) numBytes;
- (XRProcess *) processForPid: (int) pid;
- (void) runQuitSheet;

- (void) setSelectedProcess: (int)value;
- (void) selectProcess: (XRProcess *) process;
- (void) setMonitorType: (XRMonitorType) type;
- (XRProcess *) selectedProcess;

- (IBAction) stop: (id) sender;
- (IBAction) processFilterChanged: (id) sender;

@end
